package com.jdls.tanhua.web;

import com.jdls.tanhua.server.BaiduServer;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

@RestController
@RequestMapping("/baidu")
public class BaiduWeb {

    @Autowired
    private BaiduServer baiduServer;

    /**
     * 更新位置
     */
    @PostMapping("/location")
    public ResponseEntity updateLocation(@RequestBody Map param) {

        //获取经度
        Double longitude = Double.valueOf(param.get("longitude").toString());
        //获取纬度
        Double latitude = Double.valueOf(param.get("latitude").toString());
        //获取地理位置
        String address = param.get("addrStr").toString();
        //调用Server
        this.baiduServer.updateLocation(longitude, latitude,address);
        return ResponseEntity.ok(null);
    }
}